package org.example.project.service.impl;

import org.example.project.dao.CommentDao;
import org.example.project.entity.Comment;
import org.example.project.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 岩
 * @Package org.example.project.service.impl
 * @Project MyApp
 * @Name CommentServiceImpl
 * @Date 2024-04-27 20:06
 * @Filename CommentServiceImpl
 */

@Service("commentService")
public class CommentServiceImpl implements CommentService {
    @Resource
    private CommentDao commentDao;

    @Override
    public List<Comment> queryAll(int postId) {
        return this.commentDao.queryAll(postId);
    }

    @Override
    public Comment queryById(int commentId) {
        return this.commentDao.queryById(commentId);
    }

    @Override
    public Comment publish(Comment comment) {
        this.commentDao.publish(comment);
        return this.commentDao.queryById(comment.getId());
    }

    @Override
    public Boolean delete(int commentId) {
        return this.commentDao.delete(commentId) > 0;
    }

    @Override
    public Boolean like(int commentId) {
        return this.commentDao.like(commentId) > 0;
    }
}
